package com.jwds.digital.bios.business.service.anomaly;

import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltPerformanceMinute;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

public class AnomalyVerifyDB {

    private static   final Map<Long, Long> ROUTE_IDS = new HashMap<>();
    private static final Map<Long, Long> TASK_IDS = new HashMap<>();
    private static final Map<Long, BigDecimal> LOAD_RATES = new HashMap<>();
    private static final Map<Long, BigDecimal> NO_LOAD_RATES = new HashMap<>();
    private static final Map<Long, String> FIVE_PREVENTIONS = new HashMap<>();
    private static final Map<Long, BigDecimal> OPERATION_EFFICIENCY = new HashMap<>();
    private static final Map<Long, BigDecimal> OPERATION_RESISTANCE = new HashMap<>();
    private static final Map<Long, BigDecimal> NO_LOAD_RESISTANCE = new HashMap<>();





    public void addBeltPerformanceMinute(BeltPerformanceMinute beltPerformanceMinute) {
        if (beltPerformanceMinute.getLoadStatus()==1){
            LOAD_RATES.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getAvgLoadRate());
        }
        if (beltPerformanceMinute.getLoadStatus()==0){
            NO_LOAD_RATES.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getAvgLoadRate());

            NO_LOAD_RESISTANCE.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getAvgResistance());
        }
        ROUTE_IDS.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getRouteId());
        TASK_IDS.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getTaskId());
        OPERATION_EFFICIENCY.put(beltPerformanceMinute.getBeltId(), beltPerformanceMinute.getOperationEfficiency());
    }

    public void addBeltFivePrevention(Long beltId, String deductionCode) {
        //添加 FiveProtectionScore
        FIVE_PREVENTIONS.put(beltId,deductionCode);
    }


    public static BigDecimal getLoadRate(Long beltId) {
        return LOAD_RATES.get(beltId);
    }

    public static BigDecimal getNoLoadRate(Long beltId) {
        return NO_LOAD_RATES.get(beltId);
    }

    public static Long getRouteId(Long beltId) {
        return ROUTE_IDS.get(beltId);
    }

    public static Long getTaskId(Long beltId) {
        return TASK_IDS.get(beltId);
    }

    public static BigDecimal getOperationEfficiency(Long beltId) {
        return OPERATION_EFFICIENCY.get(beltId);
    }

    public static BigDecimal getOperationResistance(Long beltId) {
        return OPERATION_RESISTANCE.get(beltId);
    }

    public static BigDecimal getNoLoadResistance(Long beltId) {
        return NO_LOAD_RESISTANCE.get(beltId);
    }
}
